package com.ptrsystem.siatd.controllers;

import com.ptrsystem.siatd.beans.SedeOrganizacional;
import com.ptrsystem.siatd.dao.logica.mantenimientoSedeOrganLogica;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class SedeOrganizacionalController {

    @Autowired
    private mantenimientoSedeOrganLogica logica;

    @RequestMapping(value = "registraSedeOrganizacional.htm", method = RequestMethod.GET)
    private String registraSedOrganizacional(HttpServletRequest req) {
        req.getSession(false).setAttribute("result", "estado de Mantenimiento");
        return "Mantenimiento/NSedeOrganizacional";
    }

    @RequestMapping(value = "regNueSedOrg.htm", method = RequestMethod.POST)
    private String registarNuevaSedeOrganizacional(HttpServletRequest req, SedeOrganizacional sedeOrg) {
        boolean rs = logica.registraSedeOrgan(sedeOrg);
        if (rs) {
            req.getSession(false).setAttribute("result", "registro correcto");
        } else {
            req.getSession(false).setAttribute("result", "fallido al registrar");
        }
        return "Mantenimiento/NSedeOrganizacional";
    }

}
